package com.jian.notsafeshow;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @author Jiange
 * @create 2021-07-16-11:10
 */
public class MapShow {
    public static void main(String[] args) {
        Map<String,String> strings = new HashMap<>();

        for (int i = 0; i < 10; i++) {
            String s = String.valueOf(i);
            new Thread(()->{
                for (int j = 0; j < 10; j++) {
                    //java.util.ConcurrentModificationException 并发修改异常 add不是同步方法
                    strings.put(UUID.randomUUID().toString().substring(0,8),s);
                    System.out.println(strings);
                }
            },String.valueOf(i)).start();
        }
    }
}
